/**
 * Created by 都大爽 on 2017/11/20.
 */
export default {
  clientId: '2',
  clientSecret: 'ZKpLRitwLc3FSV1CGZ6ucJ9ev7QYOsEXRWKkA06X',

  /**
   * 登录
   * @param loginAttempts
   * @param cb
   */
  login (loginAttempts, cb, cbError) {
    console.log('login')
    let self = this
    axios.post('/oauth/token', {
      grant_type: 'password',
      client_id: self.clientId,
      client_secret: self.clientSecret,
      username: loginAttempts.username,
      password: loginAttempts.password,
      scope: ''
    }).then(response => {
      cb(response)
    }).catch(error => {
      cbError(error)
    })
  },
  /**
   *
   * @param cb
   */
  logout (cb) {
    axios.post('/logout').then(response => {
      cb(response)
    })
  }
}